package com.leorui.schoollife.utils

import com.leorui.schoollife.entity.SchoolAnnouncementDetailEntity


fun main() {
    var errorMessage: String? = null
    var detailEntity: SchoolAnnouncementDetailEntity? = null
    val okHttpUtils = OkHttpUtils()
    okHttpUtils.init()
    okHttpUtils.callback = object : OkHttpUtils.IntelCallback {
        override fun onError(msg: String?) {
            errorMessage = msg
        }

        override fun onResponse(html: String?) {
            detailEntity = SchoolParseUtils.parseDetailPage(1, html
                    ?: "", "http://xyw.hlju.edu.cn")
        }
    }
    okHttpUtils.postExecute("http://xyw.hlju.edu.cn/content.jsp?urltype=news.NewsContentUrl&wbtreeid=1123&wbnewsid=89319")

    println("----------------------------------------------------")
    println(detailEntity?.title)
    println(detailEntity?.time)
    println(detailEntity?.author)
    detailEntity?.contentList?.forEachIndexed { index: Int, s: String? ->
        println("contentList: "+s)
        if (index < detailEntity?.imgList?.size ?: 0) {
            println("imgList: "+detailEntity?.imgList?.get(index))
        }
    }
}